﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BioAttendance
{
    public partial class WebCamDailog : Form
    {
        private WebCamCapture WebCamCapture;
        public Image photo;
        public WebCamDailog()
        {
            InitializeComponent();
        }

        private void WebCamDailog_Load(object sender, System.EventArgs e)
        {
            this.WebCamCapture.TimeToCapture_milliseconds = 20;
            this.WebCamCapture.Start(0);
        }
        
        private void WebCamCapture_ImageCaptured(object source, WebcamEventArgs e)
        {
            // set the picturebox picture
            this.PicrureBox.Image = e.WebCamImage;
        }

        private void Capture_Click(object sender, EventArgs e)
        {
            this.photo = this.PicrureBox.Image;
            this.WebCamCapture.Stop();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void WebCamDailog_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.WebCamCapture.Stop();
        }
    }
}
